import {defineStore} from 'pinia'
import { computed, ref } from 'vue'
import { userGetInfoService } from '@/api/user'

export const useUserStore = defineStore('big-user',()=>{
	const token = ref('')
	
	function setToken(val){
		token.value = val
	}
	
	function removeToken(val){
		token.value = ''
	}
	
	const user = ref({})
	
	function getUser(){
		userGetInfoService().then(res=>{
			user.value = res.data.data
		})
	}
	
	function setUser(val){
		user.value = val
	}
	
	return{
		token,
		setToken,
		removeToken,
		user,
		getUser
	}
},
{
	persist:true
})